﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SpiderHelper.Model
{
    /// <summary>
    /// 采集源网站
    /// </summary>
    public class CollectionSite
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 站点名称
        /// </summary>
        public string SiteName { get; set; }
        /// <summary>
        /// 网站LOGO
        /// </summary>
        public string Logo { get; set; }
        /// <summary>
        /// 字符集编码
        /// </summary>
        public string Encode { get; set; }
        /// <summary>
        /// 是否订阅
        /// </summary>
        public int Subscribe { get; set; }

        public CollectionSite()
        {
            this.Id = int.MinValue;
            this.Subscribe = int.MinValue;
        }

        public List<CollectionSite> GetList()
        {
            DavidDB.ADO.DBManager db = new DavidDB.ADO.DBManager();
            List<CollectionSite> _sites = new List<CollectionSite>();
            CollectionSite site = new CollectionSite();
            site.Subscribe = 1;
            List<object> objs = db.GetSomeObject(site);
            foreach (CollectionSite s in objs)
            {
                _sites.Add(s);
            }
            db.Commit();
            db.Dispose();
            _sites = _sites.OrderBy(a => a.Id).ToList();
            return _sites;
        }

        public CollectionSite GetModel(int id)
        {
            CollectionSite site = new CollectionSite();
            site.Id = id;
            site = (CollectionSite)Common.ADO.DBManager.GetModel(site);
            return site;
        }
    }
}
